* This do-file re-produces Figures 3 and 4

use allmodes, clear

* Trim the weighting for all surveys at 7
replace weight=7 if weight>7

* Clean up coding of knowledge variable
replace know4_n=know4 if mode==2 
replace know4_n=know4_n*100 if know4_n<1 & mode~=1

* Generate variable for whether R's guess on unemployment is within 1 point of actual rate
gen unemploy_correct=1 if know4_n>=8.7 & know4_n<=10.7
replace unemploy_correct=0 if know4_n<8.7 | (know4_n>10.7 & know4_n~=.)

* Make smokenow "Not at all" if R has not smoked during lifetime
replace smokenow=3 if smoke100==2

* Gen variable for whether House control question is correct

recode know2 2/4=0, gen(house_correct)

* Create one variable for R's state of residence
gen state=askstate
replace state=inputstate if state==.

* Merge in dataset indicating the party of the governor in R's state
sort state
merge state using govpartydata
drop _m

* Create variable indicating whether R knew the party of his/her governor
gen govparty_correct=1 if know1==1 & partyofgov==1
replace govparty_correct=1 if know1==2 & partyofgov==0
replace govparty_correct=1 if know1==3 & state==12
replace govparty_correct=0 if govparty_correct==.
replace govparty_correct=. if know1==.

* Generate a variable counting the number of correct answers to three knowledge questions
gen knowledge=unemploy_correct+house_correct+govparty_correct

* Recode Mode to allow for easier graphing
drop if mode==3
recode mode 4=3

* Generate indicator for whether R has internet at home
tab internethome, gen(internet)
ren internet3 nointernet

* Generate estimates for Figure 4
svy: proportion house_correct if nointernet==0, over(mode)
parmest, saving(hcno, replace)
svy: proportion govparty_correct if nointernet==0, over(mode)
parmest, saving(gcno, replace)
svy: proportion unemploy_correct if nointernet==0, over(mode)
parmest, saving(ucno, replace)

* Generate estimates for first panel of Figure 3
svy: proportion house_correct if mode==2, over(nointernet)
parmest, saving(hcph, replace)
svy: proportion govparty_correct if mode==2, over(nointernet)
parmest, saving(gcph, replace)
svy: proportion unemploy_correct if mode==2, over(nointernet)
parmest, saving(ucph, replace)

* Generate estimates for first panel of Figure 4
svy: proportion house_correct if mode==3, over(nointernet)
parmest, saving(hcml, replace)
svy: proportion govparty_correct if mode==3, over(nointernet)
parmest, saving(gcml, replace)
svy: proportion unemploy_correct if mode==3, over(nointernet)
parmest, saving(ucml, replace)


*** The following commands create the figures from the datasets generated by code above
use hcno, clear
replace eq="Correct-Party Control House" if eq=="_prop_2"
drop if eq=="_prop_1"
append using gcno
replace eq="Correct-Unemployment Rate" if eq=="_prop_2"
drop if eq=="_prop_1"
append using ucno
replace eq="Correct-Gov. Party" if eq=="_prop_2"
drop if eq=="_prop_1"
encode parm, gen(mode)
encode eq, gen(response)
gen axis2=(response*5)+mode
twoway bar estimate axis2 if mode==1,  horizontal  barw(.5) lc(none) fc(gs4) || bar estimate axis2 if mode==2,  fc(gs10) horizontal barw(.5) lc(none)  || bar estimate axis2 if mode==3, fc(gs16) horizontal barw(.5) lc(none)  || rcap min95 max95 axis2, horizontal ylabel(7 "Gov. Party" 12 "Pty. Cntrl. House" 17 "Unemployment", angle(0)) ytitle("")  lc(black) xlabel(0 .2 .4 .6 .8) legend(label(1 "Internet") label(2 "Phone") label(3 "Mail") label(4 "95% CI")) graphr(c(white)) title("Political Knowledge", c(black)) saving(knowledge_internet.gph, replace) scheme(s1mono) aspect(1)
graph export figure4.pdf, replace

use hcph, clear
replace eq="Correct-Party Control House" if eq=="_prop_2"
drop if eq=="_prop_1"
append using gcph
replace eq="Correct-Unemployment Rate" if eq=="_prop_2"
drop if eq=="_prop_1"
append using ucph
replace eq="Correct-Gov. Party" if eq=="_prop_2"
drop if eq=="_prop_1"
encode parm, gen(internet)
encode eq, gen(response)
gen axis2=(response*5)+internet
twoway bar estimate axis2 if internet==1,  horizontal  barw(.5) lc(none) || bar estimate axis2 if internet==2,  horizontal barw(.5) lc(none)  || rcap min95 max95 axis2, horizontal ylabel(6.5 "Gov. Party" 11.5 "Pty. Cntrl. House" 16.5 "Unemployment", angle(0)) ytitle("")  lc(black) xlabel(0 .2 .4 .6 .8) legend(label(1 "Internet at Home") label(2 "No Internet at Home") label(3 "95% CI") c(1)) graphr(c(white)) title("Phone Respondents", c(black)) saving(knowledge_phone.gph, replace) scheme(s1mono) aspect(1)

use hcml, clear
replace eq="Correct-Party Control House" if eq=="_prop_2"
drop if eq=="_prop_1"
append using gcml
replace eq="Correct-Unemployment Rate" if eq=="_prop_2"
drop if eq=="_prop_1"
append using ucml
replace eq="Correct-Gov. Party" if eq=="_prop_2"
drop if eq=="_prop_1"
encode parm, gen(internet)
encode eq, gen(response)
gen axis2=(response*5)+internet
twoway bar estimate axis2 if internet==1,  horizontal  barw(.5) lc(none) || bar estimate axis2 if internet==2,  horizontal barw(.5) lc(none)  || rcap min95 max95 axis2, horizontal ylabel(6.5 "Gov. Party" 11.5 "Pty. Cntrl. House" 16.5 "Unemployment", angle(0)) ytitle("")  lc(black) xlabel(0 .2 .4 .6 .8) legend(label(1 "Internet at Home") label(2 "No Internet at Home") label(3 "95% CI") c(1)) graphr(c(white)) title("Mail Respondents", c(black)) saving(knowledge_mail.gph, replace) scheme(s1mono) aspect(1)

graph combine knowledge_phone.gph knowledge_mail.gph, c(2) xcommon graphr(c(white))
graph export figure3.pdf, replace

